<?php


namespace App\Models\Traits;


trait Btn
{
    public function Btn(string $route,$html,$cal='')
    {
        $type = '';
        switch ($html) {
            case 'del':
                $type = '&#xe6e2;';
                $cal = 'delbtn';
                break;
            case 'edit':
                $type = '&#xe6df;';
                break;
            case 'role':
                return '';
            default:
                # code...
                break;
        }
        return $this->allBtn($route,$type,$cal);
    }


    //共用方法
    public function allBtn(string $route,$html,$cal=''){
        if(auth()->user()->username != config('rbac.super') && !in_array($route,request()->auth))
        {
            return '';
        }
        return '<a title="删除" data-href="'.route($route,$this).'" class="ml-5'.$cal.'" style="text-decoration:none"><i class="Hui-iconfont">'.$html.'</i></a>';
    }
}